<?php
namespace common\models;

use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;

/**
 * 提示消息模型
 * @author WJ
 */
class ARMessagePrompt extends ActiveRecord
{
    public static $params = [
        // 'register'  =>  ['type' =>  self::TYPE_NOTICE, 'message'    =>  '%s，感谢您注册成功，现在就去发布购币/售币需求吧'],
        'name-auth'     => ['type' => self::TYPE_NOTICE, 'message' => '您的实名认证审核已经通过！'],
        'apply-broker'  => ['type' => self::TYPE_NOTICE, 'message' => '您已授权成为经纪人'],
        'cancel-broker' => ['type' => self::TYPE_NOTICE, 'message' => '您已取消授权成为经纪人！'],

        'join-need'     => ['type' => self::TYPE_MSG, 'message' => '%s加入您发起的广告'],
        'select-broker' => ['type' => self::TYPE_MSG, 'message' => '%s发起的交易已选择您作为经纪人'],
    ];

    const TYPE_NOTICE = 1;
    const TYPE_MSG = 2;

    const READ_IS = 1;
    const READ_NOT = -1;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%message_prompt}}';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'uid'     => '用户编号',
            'type'    => '消息类型',
            'order_id' => '订单编号',
            'message' => '消息内容',
            'message_detail' => '消息内容',
            'is_read' => '是否已读',
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'type', 'order_id', 'message', 'message_detail', 'is_read'], 'safe'],
            ['is_read', 'default', 'value' => self::READ_NOT],
        ];
    }
}
